﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;


public partial class ReferenceBook : System.Web.UI.Page
{
    ///<summary>
    /// Shows the Panel dispalaing individual books item 
    /// and hides the Panel that displays the list of books items 
    /// Also hides the image if none is defined
    ///</summary>
    protected void Page_Load(object sender, EventArgs e)
    {
        // show all books or just one item depending on querystring
        string booksItemId = Request.QueryString["booksId"];
        if (booksItemId == null)
        {
            AllBooksPanel.Visible = true;
            BooksDetailPanel.Visible = false;
            GridViewAllBooks.DataBind();
        }
        else
        {
            AllBooksPanel.Visible = false;
            BooksDetailPanel.Visible = true;
            DetailsViewBooks.DataBind();
        }
    }


    ///<summary>
    /// Hides rows that have 'invisible' = false
    /// Also hides the image if none is defined
    ///</summary>
    protected void GridViewAllBooks_RowCreated(object source, GridViewRowEventArgs e)
    {
        if (e.Row == null) return;
        // display image if a url is specified
        string bImageUrl = (string)DataBinder.Eval(e.Row.DataItem, "bImageUrl");
        if (String.Empty.Equals(bImageUrl))
        {
            Image booksImage = (Image)e.Row.FindControl("Image2");
            if (booksImage != null)
                booksImage.Visible = false;
        }
    }
    /// <summary>
    /// 提交按钮事件
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void tijiaoclick(object sender, EventArgs e)
    {    string txtEmail = txtemail.Text;
        string txtYaoqiu = txtyaoqiu.Text;
        if (txtEmail !="")
        {
            SqlEmailProvider tijiaoemail = new SqlEmailProvider();

            tijiaoemail.InsertEmail(txtEmail, txtYaoqiu);
            txtemail.Text = "";
            txtyaoqiu.Text = "";
            string strScript = "<script language=javascript>alert('邮件发送已成功，我们会尽快给您回复！');</script>";
            this.Page.RegisterStartupScript("ShowTipMsg", strScript);
            
        }
    }
    protected void quxiaoclick(object sender, EventArgs e)
    {
        txtemail.Text = "";
        txtyaoqiu.Text = "";
         
     }
}
